﻿using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using System.Web;
using TalentDesk.Contracts.Ef;
using TalentDesk.Data;

namespace TalentDesk.WcfService.EFQueries
{
    internal static class AuthenticationServiceEFQueries
    {
        public static readonly Func<TalentDeskEntities, string, string, IQueryable<User>> AuthenticateUser_CQ =
            CompiledQuery.Compile<TalentDeskEntities, string, string, IQueryable<User>>(
            (ctx, loginName, password) => from user in ctx.Users
                                          where user.UserName == loginName && user.Password == password && user.IsActive == true
                                          select user);

        public static readonly Func<TalentDeskEntities, bool, IQueryable<Menu>> GetMenus_CQ =
           CompiledQuery.Compile<TalentDeskEntities, bool, IQueryable<Menu>>(
           (ctx, isActive) => from m in ctx.Menus.Include("Action")
                              where m.IsActive == isActive
                              select m);



    }
}